import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import {createSvgIconsPlugin} from 'vite-plugin-svg-icons'
import Components from 'unplugin-vue-components/vite';
import {AntDesignVueResolver} from 'unplugin-vue-components/resolvers';
import UnoCSS from 'unocss/vite'
import path from 'path'

export default defineConfig({
    plugins: [
        vue(),
        vueJsx(),
        vueDevTools(),
        // svg-sprite-icons
        createSvgIconsPlugin({
            iconDirs: [path.resolve(__dirname, 'src/icon/svg')],
            symbolId: 'icon-[name]',
            inject: 'body-last'
        }),
        // 按需加载ant-design-vue组件
        Components({
            resolvers: [
                AntDesignVueResolver({
                    importStyle: false, // css in js
                }),
            ],
        }),
        // UnoCss支持
        UnoCSS(),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    define: {
        __APP_VERSION__: JSON.stringify('1.0.0') // 定义一个全局变量
    },
    assetsInclude: ['**/*.cur'] // 处理 .cur 文件
})

